import type { Store } from 'vuex'
import ele from './app/ele-store'
import app from './app/app-store'
import auth from './user/auth-store'

// APP
export const appStore: Store<AppStore> = app
export const appState: AppStore = app.state
export const appGetters: AppGatters = app.getters
export const appDispatch: Function = app.dispatch

// ELE
export const eleStore: Store<EleStore> = ele
export const eleState: EleStore = ele.state
export const eleDispatch: Function = ele.dispatch
export const eleReFresh: (n: ELE_STORE_FIELD, v: any) => void = 
    (n: ELE_STORE_FIELD, v: any) => ele.dispatch('change', [ n, v ])
    
// AUTH
export const authStore: Store<AuthStore> = auth
export const authState: AuthStore = auth.state
export const authGetters: AuthGetters = auth.getters
export const authDispatch: Function = auth.dispatch
export const authReFresh: (n: AUTH_STORE_FIELD, v: any) => void = 
    (n: AUTH_STORE_FIELD, v: any) => auth.dispatch('change', [ n, v ])
export const needLogin = async (): Promise<boolean> => await auth.dispatch('need_login')
